// Layer audio to time remap - Version 1.0

// This Program Sets the value of the first set of popups
// to the audio level of the layer in popup 2, scaled to lie within the range [min, max].
// It only applies keyframes during the duration of the audio layer.

// LAYER										PROPERTY					CHANNEL
// ------										----------				--------
// 1: Layer to copy audio amplitude into		property to vary			channel of property
// 2: Layer with audio							doesn't matter				doesn't matter

max = 0.02;		// change this to the maximum value
min = -0.02;			// change this to the minimum value

if (time() == start_time) {	//initialization
	audio_in	= layer_time_bounds(pop_layer(2))[0] ;
	audio_out	= layer_time_bounds(pop_layer(2))[1] ;
}

if ( (time() >= audio_in) && (time() <= audio_out) ) {

	value(pop_layer(1), pop_property(1)) [pop_channel(1)] = 
	     min + layer_audio_amplitude(pop_layer(2)) * (max - min) +
		value(pop_layer(1), pop_property(1)) [pop_channel(1)];

}
